Skip to main content

Kubernetes

Kubernetes also known as K8s or "kube" is an open source container orchestration platform that automates many of the manual processes involved in deploying, managing, and scaling containerized applications. In simple words Kubernetes is an open source system for automating deployment, scaling, and management of containerized applications.It groups * that make up an application into logical units for easy management and discovery.

Kubernetes was originally developed and designed by engineers at Google as a way to orchestrate * and afterwards Google donated the Kubernetes project to the newly formed Cloud Native Computing Foundation (CNCF) in 2015 which serves as vendor-neutral home for open source projects like Kubernetes.

We have came across 'Containers' a lot of time in this document. So lets have a look on what are Containers before diving deep into Kubernetes.

What Are Containers?

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. It is a is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings. If you still can't get it let me explain further.

This represents an hardware infrastructure on which an operating system (OS) runs, and several applications like Web server, Database etc. are sharing same dependencies and libraries that are installed over the Operating System (OS) to run. Now sharing same dependencies and libraries cause problem as these applications may need different versions of libraries and dependencies which may not be compatible for other applications. Solution came with the introduction of Containers that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.

Containers gave compelling advantages and solved a lot of problems in automation, multi-cloud systems, microservices etc.

  • Portability - Containers can run anywhere, as long as the container engine supports the underlying operating system
  • Speed - We can start, create, replicate and destroy in seconds.
  • Scalability - Containers make it easy to horizontally scale distributed applications and we can add multiple, identical * to create more instances of the same application.
  • Container Isolation - When * crash, or applications within them fail, other container running the same application can continue to run as usual.

What problem does Kubernetes solve?

Kubernetes gives us a platform to schedule and run on clusters of physical or virtual machines (VMs) and it also helps developers in creating cloud-native apps with Kubernetes as a runtime platform by using Kubernetes patterns. Now a days more oragnizations are trying to support their micro-service architecture that can help them work in multiple small teams supporting individual application modules, to be developed and deployed with the required speed and agility and this all can be only possible with the help of container orchestration tool like Kubernetes. Kubernetes orchestration allows us to build application services that span multiple , schedule those across a cluster, scale those , and manage the health of those * over time. With Kubernetes we can take effective steps toward better IT security. With Kubernetes we can:

  • Orchestrate * across multiple hosts.
  • Control and automate application deployments and updates.
  • Health-check and self-heal your apps with autoplacement, autorestart, autoreplication, and autoscaling.
  • Declaratively manage services, which guarantees the deployed applications are always running the way you intended them to run and a lot more.
  • Reliable infrastructure to support data recovery with ease.

How does Kubernetes work?

  • Nodes - These machines perform the requested tasks assigned by the control plane.
  • Control plane - The collection of processes that control Kubernetes nodes. This is where all task assignments originate.
  • Kubelet - This service runs on nodes, reads the container manifests, and ensures the defined * are started and running.
  • Kubectl - The command line configuration tool for Kubernetes.
  • Pod - A pod is a group of one or more deployed to a single node. All in a pod share an IP address, IPC, hostname, and other resources.
  • Etcd - Its main purpose is to store configuration data that's accessible to each node in the Kubernetes cluster.
  • Kube-controller-manager - The primary role of this service is to maintain the state of a cluster, such as the number of replicas.
  • Replication controlle - This controls how many identical copies of a pod should be running somewhere on the cluster.
  • Kube-proxy - kube-proxy is a network proxy that runs on each node in your cluster, implementing part of the Kubernetes Service concept.
  • Kube-apiserver - The Kubernetes API server validates and configures data for the api objects which include pods, services, replicationcontrollers, and others.

A working Kubernetes deployment is called a cluster and we can visualize a Kubernetes cluster as two parts: the control plane and the compute machines, or nodes where each node can be either a physical or virtual machine and each one of nodes runs pods which are made of several *. The Kubernetes control plane takes the commands from an administrator and relays those instructions to the compute machines and is also responsible for maintaining desired state of cluster.

Configure projects with Kubernetes

Prerequisities:

  • Install Docker for Desktop
  • Load kubectl with the instructions given
  • Install Kind or Minibuke.

Steps to configure project.

  • Create a local Kubernetes cluster - Kind deploys the Kubernetes instance in a Docker container. If you have other * running on your system, it's best to stop them. This process will take some time and after some time amessage will came that the Cluster is ready.
  • Deploy an application - Now that the cluster is up and running, we can run a process. Remember kubernetes describes all workloads through a simple yaml format file called a "manifest". So, to set up something on the cluster we need to write a yaml file to describe what we want to run and then deplu it on the cluster.
  • Expose the Deployment - For exposing the deployment we need to create a Service object that exposes an external IP address and then we can use the service object to access the running application.

References: